<?php
/**
 * Created by PhpStorm.
 * User: m1514
 * Date: 2016/12/27
 * Time: 13:26
 */

namespace Admin\Controller;


class GenrdAttrController extends LoginController
{
    public function index(){
        //获取数据
        $tid=I('get.tid');
        $aa['tid']=$tid;
        $AttrData=M('type_attr')->where($aa)->select();
//        dd($AttrData);
        $this->assign('AttrData',$AttrData);
        //显示模板
        $this->display();
    }
    //属性添加
    public function add(){
        if(IS_POST){
            $data=I('post.');
            $data['tid']=I('get.tid');
            $this->store(new \Common\Model\GenrdAttrModel(),$data,function(){
                $this->success('操作成功',u('index'));die;
            });
        }
        //显示模板
        $this->display();
    }
    public function edit(){
        //获取旧数据
        $aa=I('get.taid');
        $AttrEdit=M('type_attr')->find($aa);
        $this->assign('AttrEdit',$AttrEdit);
        //编辑功能
        if(IS_POST){
            $data=I('post.');
            $data['taid']=I('get.taid');
            $this->store(new \Common\Model\GenrdAttrModel(),$data,function(){
                $this->success('操作成功',u('index/',['tid'=>I('get.tid')]));die;
            });
        }
        //显示模板
        $this->display();
    }
    //删除
    public function del(){
        $del=I('get.taid');
        $AttrDel=M('type_attr')->delete($del);
        if($AttrDel){
            $this->success('操作成功',u('index'));die;
        }
    }
}